<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">

      <el-form-item prop="carrierId">
        <el-select v-model="queryParams.carrierId" placeholder="承运商" clearable size="small">
          <el-option v-for="item in carrierOptions" :key="item.id" :label="item.nickName" :value="item.id" />
        </el-select>
      </el-form-item>

      <!-- <el-form-item label="所属机构" prop="deptId">
        <treeselect v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="请选择所属机构"
          style="width: 214px" size="small" />
      </el-form-item> -->

      <el-form-item prop="carNumber">
        <el-input v-model="queryParams.carNumber" placeholder="车牌号" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item prop="carType">
        <el-select v-model="queryParams.carType" placeholder="车辆类型" clearable size="small">
          <el-option v-for="dict in dict.type.tms_car_type" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>

      <el-form-item prop="plateColor">
        <el-select v-model="queryParams.plateColor" placeholder="车牌颜色" clearable size="small">
          <el-option v-for="dict in dict.type.tms_plate_color" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>

      <!-- <el-form-item label="所有人" prop="ownerName">
        <el-input v-model="queryParams.ownerName" placeholder="请输入所有人" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->

      <el-form-item prop="vin">
        <el-input v-model="queryParams.vin" placeholder="车辆识别代号(VIN)" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <!-- <el-form-item label="合作类型" prop="cooperation">
        <el-select v-model="queryParams.cooperation" placeholder="请选择合作类型" clearable size="small">
          <el-option v-for="dict in dict.type.tms_car_cooperation_type" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item> -->

      <el-form-item prop="energyType">
        <el-select v-model="queryParams.energyType" placeholder="能源类型" clearable size="small">
          <el-option v-for="dict in dict.type.tms_energy_type" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>

      <el-form-item prop="engineNo">
        <el-input v-model="queryParams.engineNo" placeholder="发动机号码" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <!-- <el-form-item label="车辆状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择车辆状态" clearable size="small">
          <el-option v-for="dict in dict.type.tms_car_status" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
 -->

      <!-- <el-form-item label="删除标志" prop="delFlag">
        <el-select v-model="queryParams.delFlag" placeholder="请选择删除标志" clearable size="small">
          <el-option
            v-for="dict in dict.type.sys_del_flag"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item> -->

      <!-- <el-form-item label="使用性质" prop="useCharacter">
        <el-select v-model="queryParams.useCharacter" placeholder="请选择使用性质" clearable size="small">
          <el-option v-for="dict in dict.type.tms_use_character" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="档案编号" prop="fileNo">
        <el-input v-model="queryParams.fileNo" placeholder="请输入档案编号" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->


      <!-- <el-form-item label="注册日期">
        <el-date-picker v-model="daterangeRegisterDate" size="small" style="width: 214px" value-format="yyyy-MM-dd"
          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item> -->

      <!-- <el-form-item label="发证日期">
        <el-date-picker v-model="daterangeGrantDate" size="small" style="width: 214px" value-format="yyyy-MM-dd"
          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>
 -->






      <!-- <el-form-item label="创建人" prop="createBy">
        <el-input
          v-model="queryParams.createBy"
          placeholder="请输入创建人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>


      <el-form-item label="更新人" prop="updateBy">
        <el-input
          v-model="queryParams.updateBy"
          placeholder="请输入更新人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>


      <el-form-item label="创建时间">
        <el-date-picker
          v-model="daterangeCreateTime"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item> -->

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['tms:car:add']">
          新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['tms:car:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['tms:car:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['tms:car:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="carList" @selection-change="handleSelectionChange" border stripe>
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="车辆ID" align="center" prop="id" v-if="true"/> -->
      <el-table-column label="承运商" align="center" prop="carrierName" fixed="left"width="150" />
      <el-table-column label="车牌号" align="center" prop="carNumber" fixed="left" width="150"/>
      <el-table-column label="车辆类型" align="center" prop="carType">
        <template slot-scope="scope">
          <span v-for="item in carTypeOptions" v-if="item.id == scope.row.carType">{{item.name}}</span>
        </template>
      </el-table-column>
      <el-table-column label="车牌颜色" align="center" prop="plateColor">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.tms_plate_color" :value="scope.row.plateColor" />
        </template>
      </el-table-column>
      <el-table-column label="合作类型" align="center" prop="cooperation">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.tms_car_cooperation_type" :value="scope.row.cooperation" />
        </template>
      </el-table-column>
      <el-table-column label="所有人" align="center" prop="ownerName" />
      <el-table-column label="发证机关" align="center" prop="licenseOrgan" />
      <el-table-column label="VIN" align="center" prop="vin" />
      <el-table-column label="发动机号码" align="center" prop="engineNo" width="150"/>
      <el-table-column label="发证日期" align="center" prop="grantDate" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.grantDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="总质量" align="center" prop="totalMass" />
      <el-table-column label="能源类型" align="center" prop="energyType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.tms_energy_type" :value="scope.row.energyType" />
        </template>
      </el-table-column>
      <el-table-column label="核定载人数" align="center" prop="passenger" width="100" />
      <el-table-column label="核定载质量(kg)" align="center" prop="tonnage" width="120" />
      <el-table-column label="准牵引总质量(kg)" align="center" prop="tractionMass" width="130" />
      <el-table-column label="整备质量(kg)" align="center" prop="unladenMass" width="100" />

      <!-- <el-table-column label="删除标志" align="center" prop="delFlag">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_del_flag" :value="scope.row.delFlag"/>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="所属机构id" align="center" prop="deptId" /> -->
      <!-- <el-table-column label="所属机构" align="center" prop="deptName" /> -->
      <el-table-column label="使用性质" align="center" prop="useCharacter" />
      <el-table-column label="注册日期" align="center" prop="registerDate" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.registerDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="档案编号" align="center" prop="fileNo" />
      <el-table-column label="行驶证正面" align="center" prop="vehicleFrontImg" width="180">
        <template slot-scope="scope" v-if="scope.row.vehicleFrontImg">
            <el-image :src="scope.row.vehicleFrontImg" :preview-src-list="[scope.row.vehicleFrontImg]" style="width: 120px; height: 60px;"></el-image>
        </template>
      </el-table-column>
      <el-table-column label="行驶证背面" align="center" prop="vehicleBackImg" width="180">
        <template slot-scope="scope" v-if="scope.row.vehicleBackImg">
            <el-image :src="scope.row.vehicleBackImg" :preview-src-list="[scope.row.vehicleBackImg]" style="width: 120px; height: 60px;"></el-image>
        </template>
      </el-table-column>
      <el-table-column label="车辆照片" align="center" prop="vehicleImg" width="180">
        <template slot-scope="scope" v-if="scope.row.vehicleImg">
          <el-image v-for="(pic,pindex) in scope.row.vehicleImg.split(',')"
            style="width: 60px; height: 60px;margin-right: 5px;" :src="pic" fit="scale-down"
            :preview-src-list="scope.row.vehicleImg.split(',')"></el-image>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.tms_car_status" :value="scope.row.status" />
        </template>
      </el-table-column>
      <!-- <el-table-column label="创建人" align="center" prop="createBy" /> -->
      <el-table-column label="更新人" align="center" prop="updateBy" />
      <!-- <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="120">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['tms:car:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['tms:car:remove']">删除</el-button>
        </template>
      </el-table-column> -->
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改车辆对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="880px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <!-- <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="承运商ID" prop="clientId">
              <el-select v-model="form.carrierId" placeholder="请选择承运商" clearable size="small">
              <el-option v-for="item in carrierOptions" :key="item.id" :label="item.carrierName" :value="item.id" />
            </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="车牌号" prop="carNumber">
              <el-input v-model="form.carNumber" placeholder="请输入车牌号" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="车辆类型" prop="carType">
              <el-select v-model="form.carType" placeholder="请选择车辆类型">
                <el-option v-for="dict in dict.type.tms_car_type" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="车牌颜色" prop="plateColor">
              <el-select v-model="form.plateColor" placeholder="请选择车牌颜色">
                <el-option v-for="dict in dict.type.tms_plate_color" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="合作类型" prop="cooperation">
              <el-select v-model="form.cooperation" placeholder="请选择合作类型" clearable size="small">
                <el-option v-for="dict in dict.type.tms_car_cooperation_type" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="所有人" prop="ownerName">
              <el-input v-model="form.ownerName" placeholder="请输入所有人" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="发证机关" prop="licenseOrgan">
              <el-input v-model="form.licenseOrgan" placeholder="请输入发证机关" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="车辆识别代号(VIN)" prop="vin">
              <el-input v-model="form.vin" placeholder="请输入车辆识别代号(VIN)" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="发动机号码" prop="engineNo">
              <el-input v-model="form.engineNo" placeholder="请输入发动机号码" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="发证日期" prop="grantDate">
              <el-date-picker clearable size="small" v-model="form.grantDate" type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择发证日期">
              </el-date-picker>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="总质量" prop="totalMass">
              <el-input v-model="form.totalMass" placeholder="请输入总质量" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="能源类型" prop="energyType">
              <el-select v-model="form.energyType" placeholder="请选择能源类型">
                <el-option v-for="dict in dict.type.tms_energy_type" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="核定载人数" prop="passenger">
              <el-input v-model="form.passenger" placeholder="请输入核定载人数" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="核定载质量(kg)" prop="tonnage">
              <el-input v-model="form.tonnage" placeholder="请输入核定载质量(kg)" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="准牵引总质量(kg)" prop="tractionMass">
              <el-input v-model="form.tractionMass" placeholder="请输入准牵引总质量(kg)" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="整备质量(kg)" prop="unladenMass">
              <el-input v-model="form.unladenMass" placeholder="请输入整备质量(kg)" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="车辆状态">
              <el-radio-group v-model="form.status">
                <el-radio v-for="dict in dict.type.tms_car_status" :key="dict.value" :label="dict.value">{{dict.label}}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="所属机构" prop="deptId">
              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择所属机构"
              style="width: 214px" size="small" />
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="使用性质" prop="useCharacter">
              <el-select v-model="form.useCharacter" placeholder="请选择使用性质" clearable size="small">
                <el-option v-for="dict in dict.type.tms_use_character" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="注册日期" prop="registerDate">
              <el-date-picker clearable size="small" v-model="form.registerDate" type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择注册日期">
              </el-date-picker>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="行驶证正面" prop="vehicleFrontImg">
              <el-input v-model="form.vehicleFrontImg" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="行驶证背面" prop="vehicleBackImg">
              <el-input v-model="form.vehicleBackImg" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="车辆照片" prop="vehicleImg">
              <el-input v-model="form.vehicleImg" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="档案编号" prop="fileNo">
              <el-input v-model="form.fileNo" placeholder="请输入档案编号" />
            </el-form-item>
          </el-col>

        </el-row> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listCar, getCar, delCar, addCar, updateCar } from "@/api/tms/car";
import {listCarrier} from '@/api/tms/carrier';
import {treeselect} from '@/api/system/dept';
import {listCarType} from '@/api/tms/carType';
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "Car",
  dicts: ['tms_energy_type', 'tms_car_type', 'sys_del_flag', 'tms_car_status', 'tms_plate_color','tms_car_cooperation_type','tms_use_character'],
  components: {
      Treeselect
  },
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 车辆表格数据
      carList: [],
      carrierOptions:[],
      deptOptions:[],
      carTypeOptions:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 档案编号时间范围
      daterangeGrantDate: [],
      // 档案编号时间范围
      daterangeRegisterDate: [],
      // 档案编号时间范围
      daterangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        carrierId: undefined,
        carNumber: undefined,
        carType: undefined,
        plateColor: undefined,
        cooperation: undefined,
        ownerName: undefined,
        vin: undefined,
        engineNo: undefined,
        grantDate: undefined,
        energyType: undefined,
        status: undefined,
        delFlag: undefined,
        deptId: undefined,
        useCharacter: undefined,
        registerDate: undefined,
        fileNo: undefined,
        createBy: undefined,
        updateBy: undefined,
        createTime: undefined,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        carrierId: [
          { required: true, message: "承运商不能为空", trigger: "blur" }
        ],
        carNumber: [
          { required: true, message: "车牌号不能为空", trigger: "blur" }
        ],
        carType: [
          { required: true, message: "车辆类型不能为空", trigger: "change" }
        ],
        plateColor: [
          { required: true, message: "车牌颜色不能为空", trigger: "change" }
        ],
        cooperation: [
          { required: true, message: "合作类型不能为空", trigger: "blur" }
        ],
        ownerName: [
          { required: true, message: "所有人不能为空", trigger: "blur" }
        ],
        vin: [
          { required: true, message: "车辆识别代号(VIN)不能为空", trigger: "blur" }
        ],
        grantDate: [
          { required: true, message: "发证日期不能为空", trigger: "blur" }
        ],
        deptId: [
          { required: true, message: "所属机构id不能为空", trigger: "blur" }
        ],
        fileNo: [
          { required: true, message: "档案编号不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getCarrier();
    this.getTreeselect();
    this.getCarType();
  },
  activated() {
      const time = this.$route.query.t;
      if (time != null && time != this.uniqueId) {
        this.uniqueId = time;
        this.queryParams.pageNum = Number(this.$route.query.pageNum);
        this.getList();
      }
  },
  methods: {
    /** 查询车辆列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeGrantDate && '' != this.daterangeGrantDate) {
        this.queryParams.params["beginGrantDate"] = this.daterangeGrantDate[0];
        this.queryParams.params["endGrantDate"] = this.daterangeGrantDate[1];
      }
      if (null != this.daterangeRegisterDate && '' != this.daterangeRegisterDate) {
        this.queryParams.params["beginRegisterDate"] = this.daterangeRegisterDate[0];
        this.queryParams.params["endRegisterDate"] = this.daterangeRegisterDate[1];
      }
      if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
        this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
        this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
      }
      listCar(this.queryParams).then(response => {
        this.carList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
      /**查询承运商列表 */
    getCarrier(){
      listCarrier().then(response=>{
        this.carrierOptions = response.rows;
      })
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
        treeselect().then(response => {
          this.deptOptions = response.data;
        });
    },
    getCarType(){
      listCarType().then(response=>{
        this.carTypeOptions = response.rows;
      })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        clientId: undefined,
        carNumber: undefined,
        carType: undefined,
        plateColor: undefined,
        cooperation: undefined,
        ownerName: undefined,
        licenseOrgan: undefined,
        vin: undefined,
        engineNo: undefined,
        grantDate: undefined,
        totalMass: undefined,
        energyType: undefined,
        passenger: undefined,
        tonnage: undefined,
        tractionMass: undefined,
        unladenMass: undefined,
        remark: undefined,
        status: "0",
        delFlag: undefined,
        deptId: undefined,
        deptName: undefined,
        useCharacter: undefined,
        registerDate: undefined,
        vehicleFrontImg: undefined,
        vehicleBackImg: undefined,
        vehicleImg: undefined,
        fileNo: undefined,
        createBy: undefined,
        updateBy: undefined,
        createTime: undefined,
        updateTime: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeGrantDate = [];
      this.daterangeRegisterDate = [];
      this.daterangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      // this.reset();
      // this.open = true;
      // this.title = "添加车辆";
      this.$router.push({
        path: '/tms/carInfo/add',
        query: {
          pageNum: this.queryParams.pageNum
        }
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      // this.loading = true;
      // this.reset();
      // const id = row.id || this.ids
      // getCar(id).then(response => {
      //   this.loading = false;
      //   this.form = response.data;
      //   this.open = true;
      //   this.title = "修改车辆";
      // });
      const id = row.id || this.ids
      this.$router.push({
        path: '/tms/carInfo/edit/' + id,
        query: {
          pageNum: this.queryParams.pageNum
        }
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.id != null) {
            updateCar(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          } else {
            addCar(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除车辆编号为"' + ids + '"的数据项？').then(() => {
        this.loading = true;
        return delCar(ids);
      }).then(() => {
        this.loading = false;
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('tms/car/export', {
        ...this.queryParams
      }, `car_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
